import {Component, OnInit} from '@angular/core';
import {PopoverComponent} from '../product-show/popover/popover.component';
import {PopoverController} from '@ionic/angular';

@Component({
    selector: 'app-product-archive',
    templateUrl: './product-archive.page.html',
    // styleUrls: ['./product-archive.page.less'],
})
export class ProductArchivePage implements OnInit {
    currentPopover = null;
    selectTab = null; // 选中的tab标签

    constructor(
        private popover: PopoverController
    ) {
    }

    ngOnInit() {
        // 选中备料清单
        this.selectTab = 'backupList';
    }

    ionViewWillLeave() {
        // 关闭popover页面
        if (this.currentPopover) {
            this.currentPopover.dismiss().then(() => {
                this.currentPopover = null;
            });
        }
    }

    async openPopover(ev: any) {
        const popover = await this.popover.create({
            component: PopoverComponent,
            cssClass: 'my-custom-class',
            event: ev,
            translucent: true
        });
        this.currentPopover = popover;
        return await popover.present();
    }

    segmentChanged(ev: any) {
        // console.log('Segment changed', ev);
        this.selectTab = ev.detail.value;
    }

}
